<?php

namespace App\Listeners\Plane\PlaneOrder\Refund;

use App\Events\Plane\PlaneOrder\Refund\PlaneOrderTicketReturnSuccessEvent;
use Exception;

class PlaneOrderTicketReturnSuccessListener
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param object $event
     * @return void
     */
    public function handle(PlaneOrderTicketReturnSuccessEvent $event)
    {
        $return_info = $event->return;
        $notify      = $event->notify;
        $order_info  = $return_info->getOrderInfo();
//        $planeOrderRepo = app(PlaneOrderRepositoryInterface::class);
        switch ($order_info->order_service) {
            case 'book51':
                $return_info->ticket_return_success([
                    'provider_return_price' => $notify->getRefundPrice(),
                    'provider_return_fee'   => $notify->getRefundFee(),
                    'return_state'          => 1,
                ]);
                break;
            default:
                throw new Exception("order service error ");
        }
    }
}
